package example.threads;

/**
 * 
 * @author Globex Inc.
 *
 */
//public class Child implements Runnable {
public class Child extends Thread {
	
	public boolean on = true;
	public String name;
	
	public Child(String str){
		name = str;
	}
	
	public void run() {
		System.out.println(name+": I'm alive");
		System.out.println(name+": on is "+on);
		System.out.println(name+": I'm going to sleep");
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			System.out.println(name+": I've been awaken!");
		}
		
		if(Thread.interrupted())
			System.out.println(name+": Dang, I've been interrupted and I didn't even notice");
		
		System.out.println(name+": on is "+on);
		System.out.println(name+": Shutting down");
	}
	
	public void tunrOff() {
		System.out.println(name+": I'm being shut down");
		on = false;
	}
}
